﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Data.SqlClient;

namespace _19._02.CS
{
    public partial class Form1 : Form
    {
        SqlConnection SqlConnection1 = new SqlConnection();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnConnetti_Click(object sender, EventArgs e)
        {
            while (SqlConnection1.State == ConnectionState.Closed)
            {
                SqlConnection1.ConnectionString =
                  "Integrated Security=SSPI;" +
                  "Persist Security Info=False;" +
                  "User ID='sa';" +
                  "Initial Catalog=NorthWind;" +
                  "Data Source=HP;" +
                  "Initial File Name=''";
                SqlConnection1.Open();
            }
            Label1.Text = "Connesso";
        }

        private void btnDisconnetti_Click(object sender, EventArgs e)
        {
            while (SqlConnection1.State == ConnectionState.Open)
            {
                SqlConnection1.Close();
            }
            Label1.Text = "Disconnesso";
        }
    }
}
